﻿using ReverseEgns;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Collections.Generic;
using System.Text.RegularExpressions;

namespace ReverseEgns
{
    [TestClass()]
    public class ReverseEgnsTest
    {

        [TestMethod()]
        public void ExtractEgnsTest()
        {
            string filename = @"C:\Users\User\Documents\visual studio 2010\Projects\Exam_DelagatesRegexStringsInputOutput\ReverseEgns\bin\Debug\testFile.txt";
            string outputFilename = @"C:\Users\User\Documents\visual studio 2010\Projects\Exam_DelagatesRegexStringsInputOutput\ReverseEgns\bin\Debug\reversed1.txt";
            List<string> expected = new List<string>()
            {
                "I am Bay Ivan EGN: 0407403009",
                "I am Pesho EGN: 5544902159",
                "I am Gosho Visa: 9900 1222 3333 1111"
            };
            List<string> actual;
            actual = ReverseEgns.ExtractEgns(filename, outputFilename);
            Assert.AreEqual(expected.Count, actual.Count);

            for (int i = 0; i < actual.Count; i++)
            {
                Assert.AreEqual(expected[i], actual[i]);
            }
        }

        [TestMethod()]
        public void ReverseEGNTest()
        {
            string input = "1234567890";
            Match match = Regex.Match(input, @"\b[0-9]{10}\b");
            string expected = "0987654321"; 
            string actual;
            actual = ReverseEgns.ReverseEGN(match);
            Assert.AreEqual(expected, actual);
        }

        [TestMethod()]
        public void ReverseEGNChecksWhenActualIsDifferntFromExpectedTest()
        {
            string input = "1234567890";
            Match match = Regex.Match(input, @"\b[0-9]{10}\b");
            string expected = "1234567890";
            string actual;
            actual = ReverseEgns.ReverseEGN(match);
            Assert.AreNotEqual(expected, actual);
        }
    }
}
